<?php
if (!defined('BASEPATH'))
exit ('No direct script access allowed');

class Yeepay {

	var $CI;

	var $card_denomination;
	var $card_no;
	var $card_password;
	var $card_type;
	var $price;
	public function __construct() {
		$this->CI = & get_instance();

		$this->set_card_denomination();
		$this->set_card_no();
		$this->set_card_password();
		$this->set_card_type();
		$this->set_price();
	}

	private  function set_price() {
		$this->price = $this->CI->input->get_post("Price");
	}

	public function get_price() {
		if ($this->price=="") {
			$this->set_price();
		}
		return $this->price;
	}

	private function set_card_denomination() {
		$this->card_denomination = $this->CI->input->get_post("money");
// 		log_message("info","卡面额:".$this->card_denomination);
	}

	public function get_card_denomination() {
		return $this->card_denomination;
	}

	private function set_card_no() {
		$this->card_no = $this->CI->input->get_post("card_no");
	}

	public function get_card_no() {
		return $this->card_no;
	}

	private function set_card_password() {
		$this->card_password = $this->CI->input->get_post("card_password");
	}

	public function get_card_password() {
		return $this->card_password;
	}

	private function set_card_type() {
		$this->card_type = $this->CI->input->get_post("t_card_type");
	}

	public function get_card_type() {
		return $this->card_type;
	}




	/**
	 *	Created on 2013-4-15
	 *  易宝支付
	 */
	public function yeepay($data){
		$this->CI->load->helper("yeepay/yeepaycommon");
		$tcd= $data['t_card_denomination'];
		log_message("info","卡面额是".$tcd);
		log_message("info","卡号是".$data['card_no']);
		log_message("info","卡密码是".$data['card_password']);
		//支付渠道
		$pd_FrpId			=$data["t_card_type"];
		#商户订单号.提交的订单号必须在自身账户交易中唯一.
		$p2_Order			= $data['order_sn'];
		#支付卡面额
		$p3_Amt				= $data['amount'];
		#是否较验订单金额
		$p4_verifyAmt		= "true";
		#产品名称
		$p5_Pid				= iconv("UTF-8","GBK//TRANSLIT","瑞币充值");

		#产品类型
		$p6_Pcat			= "";
		#iconv("UTF-8","GBK//TRANSLIT",$_POST['p6_Pcat']);
		#产品描述
		$p7_Pdesc			= "";
		#iconv("UTF-8","GBK//TRANSLIT",$_POST['p7_Pdesc']);
		#商户接收交易结果通知的地址,易宝支付主动发送支付结果(服务器点对点通讯).通知会通过HTTP协议以GET方式到该地址上.
		$p8_Url				= $data['return_url'];
		#临时信息
		$pa_MP				= "";
		#iconv("UTF-8","GB2312//TRANSLIT",$_POST['pa_MP']);
		#卡面额
		$cardAmt=array($tcd);
		$pa7_cardAmt		= arrToStringDefault($cardAmt);
		#支付卡序列号.
		$cardNo=array($data['card_no']);
		$pa8_cardNo			= arrToStringDefault($cardNo);
		#支付卡密码.
		$cardPwd=array($data['card_password']);
		$pa9_cardPwd		= arrToStringDefault($cardPwd);
		#支付通道编码
		$pd_FrpId			=$pd_FrpId;
		#应答机制
		$pr_NeedResponse	= "1";
		#用户唯一标识
		$pz_userId			= "";
		#用户的注册时间
		$pz1_userRegTime	= "";

		$return=annulCard($p2_Order,$p3_Amt,$p4_verifyAmt,$p5_Pid,$p6_Pcat,$p7_Pdesc,$p8_Url,$pa_MP,$pa7_cardAmt,$pa8_cardNo,$pa9_cardPwd,$pd_FrpId,$pz_userId,$pz1_userRegTime);
		return $return;
	}

}
